home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / libkmid / midfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  2.8 KB  |  100 lines

  1. /*  midfile.h  - function which reads a midi file,and creates the track classes
  2.     This file is part of LibKMid 0.9.5
  3.     Copyright (C) 1997,98,99,2000  Antonio Larrosa Jimenez
  4.     LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libkmid.html
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.     Boston, MA 02110-1301, USA.
  20.  
  21.     Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
  22.  
  23.  ***************************************************************************/
  24. #ifndef _MIDFILE_H
  25. #define _MIDFILE_H
  26.  
  27. #include <libkmid/dattypes.h>
  28. #include <libkmid/track.h>
  29. #include <stdio.h>
  30. #include <kdelibs_export.h>
  31.  
  32. /**
  33.  * Contains all the information about a MIDI file.
  34.  *
  35.  * @short All the information about a MIDI file.
  36.  * @version 0.9.5 17/01/2000
  37.  * @author Antonio Larrosa Jimenez <larrosa@kde.org>
  38.  */
  39. struct MidiFileInfo
  40. {
  41.   /**
  42.    * Format of MIDI file.
  43.    */ 
  44.   int format;
  45.  
  46.   /**
  47.    * Number of tracks.
  48.    */
  49.   int ntracks;
  50.  
  51.   /**
  52.    * Ticks per cuarter note.
  53.    */
  54.   int ticksPerCuarterNote;
  55.  
  56.   /**
  57.    * Total number of MIDI ticks
  58.    */ 
  59.   ulong ticksTotal;
  60.  
  61.   /**
  62.    * Total number of milliseconds
  63.    */ 
  64.   double millisecsTotal;
  65.  
  66.   ulong ticksPlayed;
  67.  
  68.   /**
  69.    * Patches used in the MIDI file.
  70.    *
  71.    * In each position of the array it stores the number of times the
  72.    * corresponding patch is used. So, if a MIDI file plays 782 notes
  73.    * with a piano, patchesUsed[0] will store 782. In the same way, 
  74.    * if it doesn't use the Music Box patch, patchesUsed[10] will be 0. 
  75.    * 
  76.    */
  77.   int patchesUsed[256];
  78.  
  79. };
  80.  
  81. double KMID_EXPORT tempoToMetronomeTempo(ulong x);
  82. double metronomeTempoToTempo(ulong x);
  83.  
  84. /**
  85.  * Reads a midi file.
  86.  * 
  87.  * @param name the filename of the midi file to load.
  88.  * @param info a pointer to the MidiFileInfo struct that will be
  89.  *     filled with the information of the loaded file.
  90.  * @param ok return status.
  91.  * @return an array of MidiTrack objects with the contents of the file.
  92.  */ 
  93. MidiTrack **readMidiFile( const char *name, MidiFileInfo *info, int &ok);
  94.  
  95. void parseInfoData( MidiFileInfo *info, MidiTrack **tracks, float ratioTempo);
  96.  
  97. void parsePatchesUsed( MidiTrack **tracks, MidiFileInfo *info, int gm);
  98.  
  99. #endif
  100.